package com.kk.util.test.thread.example;

/**
 * @function:
 * @author: kevin
 * @date: 2018-09-07 18:12
 */
public class ObjectData {
    private int count;

    public ObjectData() {
        count = 0;
    }

    public int getCount() {
        return count;
    }

    public boolean read() {
        System.out.println("read count: " + count);
        if (count > 0) {
            return true;
        }
        return false;
    }

    public void product() {
        count++;
        System.out.println("生产了一个产品，还剩 : " + count);
    }

    public void consumer() {
        count--;
        System.out.println("消费了一个产品，还剩：" + count);
    }

    public static void main(String[] args) {
        ObjectData data = new ObjectData();
        ConsumerThread consumer = new ConsumerThread(data);
        ProductThread product = new ProductThread(data);
        consumer.start();
        product.start();
    }
}
